#!bin/bash
#

read -p "服务名: " CMD

   cmd=$(ps -elf | grep "${CMD}$" | awk '{print $15}') &> /dev/null
   pri=$(ps -elf | grep "${CMD}$" | awk '{print $7}') &> /dev/null
   pid=$(ps -elf | grep "${CMD}$" | awk '{print $4}') &> /dev/null

ps -elf | grep "$CMD" | grep -v "grep" &> /dev/null
if [ $? -ne 0 ];then
   echo "未运行"
else
   ps -elf | grep "${CMD}$" | awk '{print $4,$7,$15}' &> /dev/null
echo "服务名称:${cmd},端口:${pri},PID:${pid}"
fi
